home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LT_SetAttributes.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  25KB  |  1,158 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __stdargs
  10. LT_SetAttributes(LayoutHandle *handle,LONG id,...)
  11. {
  12.     va_list VarArgs;
  13.  
  14.     va_start(VarArgs,id);
  15.     LT_SetAttributesA(handle,id,(struct TagItem *)VarArgs);
  16.     va_end(VarArgs);
  17. }
  18.  
  19.  
  20. /*****************************************************************************/
  21.  
  22.  
  23. VOID LIBENT
  24. LT_SetAttributesA(REG(a0) LayoutHandle *handle,REG(d0) LONG id,REG(a1) struct TagItem *TagList)
  25. {
  26.     if(handle && TagList)
  27.     {
  28.         struct Gadget    *Gadget = NULL;
  29.         struct TagItem    *ThisTag,*ThisList = TagList;
  30.         ObjectNode    *Node = NULL;
  31.  
  32.         while(ThisTag = NextTagItem(&ThisList))
  33.         {
  34.             switch(ThisTag -> ti_Tag)
  35.             {
  36.                 case LH_AutoActivate:
  37.  
  38.                     handle -> AutoActivate = ThisTag -> ti_Data;
  39.                     break;
  40.  
  41.                 case LH_RawKeyFilter:
  42.  
  43.                     handle -> RawKeyFilter = ThisTag -> ti_Data;
  44.                     break;
  45.  
  46.                 case LH_UserData:
  47.  
  48.                     handle -> UserData = (APTR)ThisTag -> ti_Data;
  49.                     break;
  50.  
  51.                 case LH_ExitFlush:
  52.  
  53.                     handle -> ExitFlush = ThisTag -> ti_Data;
  54.                     break;
  55.  
  56.                 case LH_LocaleHook:
  57.  
  58.                     handle -> LocaleHook = (struct Hook *)ThisTag -> ti_Data;
  59.                     break;
  60.  
  61.                 case LAPR_Gadget:
  62.  
  63.                     Gadget = (struct Gadget *)ThisTag -> ti_Data;
  64.                     break;
  65.  
  66.                 case LAPR_Object:
  67.  
  68.                     Node = (ObjectNode *)ThisTag -> ti_Data;
  69.                     break;
  70.             }
  71.         }
  72.  
  73.         if(Node)
  74.             Gadget = Node -> Host;
  75.         else
  76.         {
  77.             if(Gadget)
  78.             {
  79.                 if(Node = (ObjectNode *)Gadget -> UserData)
  80.                 {
  81.                     if(Node -> Host != Gadget || Node -> PointBack != Node)
  82.                         Node = NULL;
  83.                 }
  84.             }
  85.         }
  86.  
  87.         if(!Gadget)
  88.         {
  89.             if(Gadget = LTP_FindGadget(handle,id))
  90.             {
  91.                 if(Node = (ObjectNode *)Gadget -> UserData)
  92.                 {
  93.                     if(Node -> Host != Gadget || Node -> PointBack != Node)
  94.                         Node = NULL;
  95.                 }
  96.             }
  97.             else
  98.                 Node = LTP_FindNode(handle -> TopGroup,id);
  99.         }
  100.  
  101.         if(Node)
  102.         {
  103.             STATIC Tag Filter[] = { GA_Disabled,TAG_DONE };
  104.  
  105.             struct TagItem    *NewTags = NULL;
  106.             ULONG         Exclude = NULL;
  107.  
  108.             switch(Node -> Type)
  109.             {
  110. #ifdef DO_BOOPSI_KIND
  111.                 case BOOPSI_KIND:
  112.  
  113.                     if(ThisTag = FindTagItem(GA_Disabled,TagList))
  114.                         Node -> Disabled = ThisTag -> ti_Data;
  115.  
  116.                     if(Node -> Special . BOOPSI . TagCurrent)
  117.                     {
  118.                         if(ThisTag = FindTagItem(Node -> Special . BOOPSI . TagCurrent,TagList))
  119.                             Node -> Current = ThisTag -> ti_Data;
  120.                     }
  121.  
  122.                     if(Node -> Host)
  123.                         SetGadgetAttrsA(Node -> Host,handle -> Window,NULL,TagList);
  124.  
  125.                     return;
  126. #endif    /* DO_BOOPSI_KIND */
  127.                 case STRING_KIND:
  128.  
  129.                     if(ThisTag = FindTagItem(GTST_String,TagList))
  130.                     {
  131.                         Exclude = GTST_String;
  132.  
  133.                         if(Gadget)
  134.                         {
  135.                             GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  136.                                 GTST_String,ThisTag -> ti_Data,
  137.                             TAG_DONE);
  138.                         }
  139.                         else
  140.                         {
  141.                             if(!Node -> Special . String . Backup)
  142.                                 Node -> Special . String . Backup = (STRPTR)LTP_Alloc(handle,Node -> Special . String . MaxChars + 1);
  143.  
  144.                             if(Node -> Special . String . Backup)
  145.                             {
  146.                                 if(ThisTag -> ti_Data)
  147.                                     strcpy(Node -> Special . String . Backup,(STRPTR)ThisTag -> ti_Data);
  148.                                 else
  149.                                     Node -> Special . String . Backup[0] = 0;
  150.  
  151.                                 Node -> Special . String . String = Node -> Special . String . Backup;
  152.                             }
  153.                         }
  154.                     }
  155.  
  156.                     if(Gadget)
  157.                     {
  158.                         if(ThisTag = FindTagItem(LAST_CursorPosition,TagList))
  159.                         {
  160.                             struct StringInfo    *StringInfo = Gadget -> SpecialInfo;
  161.                             LONG             Position,Len;
  162.  
  163.                             RemoveGList(handle -> Window,handle -> List,(UWORD)-1);
  164.  
  165.                             Position = (LONG)ThisTag -> ti_Data;
  166.  
  167.                             Len = strlen(StringInfo -> Buffer);
  168.  
  169.                             if(Position == -1)
  170.                                 Position = Len;
  171.                             else
  172.                             {
  173.                                 if(Position < 0)
  174.                                     Position = 0;
  175.                                 else
  176.                                 {
  177.                                     if(Position > Len)
  178.                                         Position = Len;
  179.                                 }
  180.                             }
  181.  
  182.                             StringInfo -> BufferPos = Position;
  183.  
  184.                             AddGList(handle -> Window,handle -> List,(UWORD)-1,(UWORD)-1,NULL);
  185.                             RefreshGList(Gadget,handle -> Window,NULL,1);
  186.                         }
  187.                     }
  188.  
  189.                     break;
  190.  
  191. #ifdef DO_LEVEL_KIND
  192.                 case LEVEL_KIND:
  193.                 {
  194.                     BOOLEAN         ChangeIt    = FALSE;
  195.                     LevelExtra    *Special    = &Node -> Special . Level;
  196.  
  197.                     if(ThisTag = FindTagItem(LAVL_Min,TagList))
  198.                     {
  199.                         Special -> Plus = Special -> Min = (LONG)ThisTag -> ti_Data;
  200.  
  201.                         ChangeIt = TRUE;
  202.                     }
  203.  
  204.                     if(ThisTag = FindTagItem(LAVL_Max,TagList))
  205.                     {
  206.                         Special -> Max = (LONG)ThisTag -> ti_Data;
  207.  
  208.                         ChangeIt = TRUE;
  209.                     }
  210.  
  211.                     if(ThisTag = FindTagItem(LAVL_Level,TagList))
  212.                     {
  213.                         Special -> Level = (LONG)ThisTag -> ti_Data;
  214.  
  215.                         LTP_PutStorage(Node);
  216.  
  217.                         ChangeIt = TRUE;
  218.                     }
  219.  
  220.                     if(Special -> Max < Special -> Min)
  221.                         Special -> Max = Special -> Min;
  222.  
  223.                     if(Special -> Level > Special -> Max)
  224.                         Special -> Level = Special -> Max;
  225.  
  226.                     if(Special -> Level < Special -> Min)
  227.                         Special -> Level = Special -> Min;
  228.  
  229.                     if(ChangeIt && Gadget && handle -> Window)
  230.                     {
  231.                         LONG Plus = Special -> Plus;
  232.  
  233.                         SetAttrs(Special -> LevelImage,
  234.                             LVIA_Current,    Special -> Level    - Plus,
  235.                             LVIA_Max,    Special -> Max        - Plus,
  236.                         TAG_DONE);
  237.  
  238.                         DrawImageState(&handle -> RPort,Special -> LevelImage,Gadget -> LeftEdge,Gadget -> TopEdge,IDS_NORMAL,handle -> DrawInfo);
  239.  
  240.                         LTP_LevelGadgetDrawLabel(Gadget,FALSE);
  241.                     }
  242.  
  243.                     break;
  244.                 }
  245. #endif    /* DO_LEVEL_KIND */
  246.                 case CHECKBOX_KIND:
  247.  
  248.                     if(ThisTag = FindTagItem(GTCB_Checked,TagList))
  249.                     {
  250.                         if((Node -> Current && ThisTag -> ti_Data) || (!Node -> Current && !ThisTag -> ti_Data))
  251.                             Exclude = GTCB_Checked;
  252.                         else
  253.                         {
  254.                             Node -> Current = ThisTag -> ti_Data;
  255.  
  256.                             LTP_PutStorage(Node);
  257.                         }
  258.                     }
  259.  
  260.                     break;
  261.  
  262. #ifdef DO_TAPEDECK_KIND
  263.                 case TAPEDECK_KIND:
  264.  
  265.                     if(ThisTag = FindTagItem(LATD_Pressed,TagList))
  266.                     {
  267.                         if(Node -> Current != ThisTag -> ti_Data && Node -> Special . TapeDeck . Toggle)
  268.                         {
  269.                             Node -> Current = ThisTag -> ti_Data;
  270.  
  271.                             if(Gadget)
  272.                             {
  273.                                 RemoveGList(handle -> Window,handle -> List,(UWORD)-1);
  274.  
  275.                                 if(Node -> Current)
  276.                                     Gadget -> Flags |= GFLG_SELECTED;
  277.                                 else
  278.                                     Gadget -> Flags &= ~GFLG_SELECTED;
  279.  
  280.                                 AddGList(handle -> Window,handle -> List,(UWORD)-1,(UWORD)-1,NULL);
  281.                                 RefreshGList(Gadget,handle -> Window,NULL,1);
  282.                             }
  283.                         }
  284.                     }
  285.  
  286.                     break;
  287. #endif    /* DO_TAPEDECK_KIND */
  288.  
  289. #ifdef DO_GAUGE_KIND
  290.                 case GAUGE_KIND:
  291.                 {
  292.                     LONG    Percent     = (LONG)Node -> Current;
  293.                     BOOLEAN NeedRefresh    = FALSE;
  294.  
  295.                     if(ThisTag = FindTagItem(LAGA_Percent,TagList))
  296.                     {
  297.                         Percent = (LONG)ThisTag -> ti_Data;
  298.  
  299.                         if(Percent < 0)
  300.                             Percent = 0;
  301.                         else
  302.                         {
  303.                             if(Percent > 100)
  304.                                 Percent = 100;
  305.                         }
  306.  
  307.                         if(Percent != (LONG)Node -> Current)
  308.                             NeedRefresh = TRUE;
  309.                     }
  310.  
  311.                     if(ThisTag = FindTagItem(LAGA_InfoText,TagList))
  312.                     {
  313.                         STRPTR SomeText = (STRPTR)ThisTag -> ti_Data;
  314.  
  315.                         if(Node -> Special . Gauge . InfoLength)
  316.                         {
  317.                             LONG Len = strlen(SomeText);
  318.  
  319.                             if(Len > Node -> Special . Gauge . InfoLength)
  320.                                 Len = Node -> Special . Gauge . InfoLength;
  321.  
  322.                             CopyMem(SomeText,Node -> Special . Gauge . InfoText,Len);
  323.  
  324.                             Node -> Special . Gauge . InfoText[Len] = 0;
  325.  
  326.                             NeedRefresh = TRUE;
  327.                         }
  328.                     }
  329.  
  330.                     if(NeedRefresh && Gadget)
  331.                         LTP_DrawGauge(handle,Node,Percent,FALSE);
  332.                 }
  333.  
  334.                 return;
  335. #endif
  336.                 case LISTVIEW_KIND:
  337.  
  338.                     if(ThisTag = FindTagItem(GTLV_Labels,TagList))
  339.                     {
  340.                         Node -> Special . List . Labels = (struct List *)ThisTag -> ti_Data;
  341.  
  342.                         if(ThisTag -> ti_Data == (ULONG)~0)
  343.                             Node -> Min = Node -> Max = -1;
  344.                         else
  345.                         {
  346.                             struct List    *List;
  347.                             LONG         Count = 0;
  348.                             struct Node    *Item;
  349.  
  350.                             if(ThisTag -> ti_Data)
  351.                                 List = (struct List *)ThisTag -> ti_Data;
  352.                             else
  353.                             {
  354.                                 STATIC Tag Filter[] = { GTLV_Labels,TAG_DONE };
  355.  
  356.                                 LONG Current = (LONG)GetTagData(GTLV_Selected,(ULONG)Node -> Current,TagList);
  357.  
  358.                                 if(!NewTags)
  359.                                 {
  360.                                     if(!(NewTags = CloneTagItems(TagList)))
  361.                                         return;
  362.                                 }
  363.  
  364.                                 FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  365.  
  366.                                 List = (struct List *)<P_EmptyList;
  367.  
  368.                                 GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  369.                                     GTLV_Labels,    List,
  370.                                     GTLV_Selected,    Current,
  371.                                 TAG_DONE);
  372.  
  373.                                 Node -> Special . List . Labels = List;
  374.                             }
  375.  
  376.                             SCANLIST(List,Item)
  377.                             {
  378.                                 Count++;
  379.                             }
  380.  
  381.                             Node -> Min = 0;
  382.  
  383.                             if(Count)
  384.                                 Node -> Max = Count - 1;
  385.                             else
  386.                                 Node -> Max = 0;
  387.                         }
  388.                     }
  389.  
  390.                     if(ThisTag = FindTagItem(GTLV_Selected,TagList))
  391.                     {
  392.                         Node -> Current = (LONG)ThisTag -> ti_Data;
  393.  
  394.                         if(Gadget)
  395.                         {
  396.                             Exclude = GTLV_Selected;
  397.  
  398.                             if(Node -> Current < 0)
  399.                             {
  400.                                 GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  401.                                     GTLV_Selected,        Node -> Current,
  402.                                     GTLV_Labels,        Node -> Special . List . Labels,
  403.                                 TAG_DONE);
  404.                             }
  405.                             else
  406.                             {
  407.                                 GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  408.                                     GTLV_Selected,        Node -> Current,
  409.                                     GTLV_Top,        Node -> Current,
  410.                                     GTLV_MakeVisible,    Node -> Current,
  411.                                     GTLV_Labels,        Node -> Special . List . Labels,
  412.                                 TAG_DONE);
  413.                             }
  414.                         }
  415.  
  416.                         LTP_PutStorage(Node);
  417.  
  418.                         if(Node -> Special . List . AutoPageID != -1)
  419.                         {
  420.                             LT_SetAttributes(handle,Node -> Special . List . AutoPageID,
  421.                                 LAGR_ActivePage,Node -> Current,
  422.                             TAG_DONE);
  423.                         }
  424.                     }
  425.  
  426.                     if(ThisTag = FindTagItem(GA_Disabled,TagList))
  427.                     {
  428.                         if(!V39)
  429.                         {
  430.                             if(!NewTags)
  431.                             {
  432.                                 if(!(NewTags = CloneTagItems(TagList)))
  433.                                     return;
  434.                             }
  435.  
  436.                             FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  437.                         }
  438.                     }
  439.  
  440.                     break;
  441.  
  442.                 case MX_KIND:
  443.  
  444.                     if(ThisTag = FindTagItem(GTMX_Active,TagList))
  445.                     {
  446.                         if(Node -> Current == ThisTag -> ti_Data)
  447.                             Exclude = GTMX_Active;
  448.                         else
  449.                         {
  450.                             Node -> Current = ThisTag -> ti_Data;
  451.  
  452.                             LTP_PutStorage(Node);
  453.  
  454.                             if(Node -> Special . Radio . AutoPageID != -1)
  455.                             {
  456.                                 LT_SetAttributes(handle,Node -> Special . Radio . AutoPageID,
  457.                                     LAGR_ActivePage,Node -> Current,
  458.                                 TAG_DONE);
  459.                             }
  460.                         }
  461.                     }
  462.  
  463.                     if(!V39)
  464.                     {
  465.                         if(FindTagItem(GA_Disabled,TagList))
  466.                         {
  467.                             if(!(NewTags = CloneTagItems(TagList)))
  468.                                 return;
  469.                             else
  470.                                 FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  471.                         }
  472.                     }
  473.  
  474.                     break;
  475.  
  476.                 case CYCLE_KIND:
  477.  
  478.                     if(ThisTag = FindTagItem(GTCY_Active,TagList))
  479.                     {
  480.                         if(Node -> Current == ThisTag -> ti_Data)
  481.                             Exclude = GTCY_Active;
  482.                         else
  483.                         {
  484.                             Node -> Current = ThisTag -> ti_Data;
  485.  
  486.                             LTP_PutStorage(Node);
  487.  
  488.                             if(Node -> Special . Cycle . AutoPageID != -1)
  489.                             {
  490.                                 LT_SetAttributes(handle,Node -> Special . Cycle . AutoPageID,
  491.                                     LAGR_ActivePage,Node -> Current,
  492.                                 TAG_DONE);
  493.                             }
  494.                         }
  495.                     }
  496.  
  497.                     if(ThisTag = FindTagItem(GTCY_Labels,TagList))
  498.                     {
  499.                         STRPTR    *Strings;
  500.                         LONG     Count = 0;
  501.  
  502.                         if(Strings = (STRPTR *)ThisTag -> ti_Data)
  503.                         {
  504.                             while(Strings[Count])
  505.                                 Count++;
  506.                         }
  507.  
  508.                         if(Count)
  509.                             Node -> Max = Count - 1;
  510.                         else
  511.                             Node -> Max = 0;
  512.                     }
  513.  
  514.                     break;
  515. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  516.                 case POPUP_KIND:
  517.                 {
  518.                     BOOL NewCurrent = FALSE,NewLabels = FALSE;
  519.  
  520.                     if(ThisTag = FindTagItem(GA_Disabled,TagList))
  521.                         Node -> Disabled = ThisTag -> ti_Data;
  522.  
  523.                     if(ThisTag = FindTagItem(LAPU_Labels,TagList))
  524.                     {
  525.                         STRPTR    *Strings;
  526.                         LONG     Count = 0;
  527.  
  528.                         if(Strings = (STRPTR *)ThisTag -> ti_Data)
  529.                         {
  530.                             while(Strings[Count])
  531.                                 Count++;
  532.                         }
  533.  
  534.                         if(Count)
  535.                             Node -> Max = Count - 1;
  536.                         else
  537.                             Node -> Max = 0;
  538.  
  539.                         Node -> Special . Popup . Choices = (STRPTR *)ThisTag -> ti_Data;
  540.  
  541.                         DB(kprintf("max: %ld\n",Node -> Max));
  542.  
  543.                         NewLabels = TRUE;
  544.                     }
  545.  
  546.                     if(ThisTag = FindTagItem(LAPU_Active,TagList))
  547.                     {
  548.                         DB(kprintf("current: %ld tag: %ld\n",Node -> Current,ThisTag -> ti_Data));
  549.  
  550.                         if(Node -> Current != ThisTag -> ti_Data)
  551.                         {
  552.                             Node -> Current = ThisTag -> ti_Data;
  553.  
  554.                             LTP_PutStorage(Node);
  555.  
  556.                             if(Node -> Special . Popup . AutoPageID != -1)
  557.                             {
  558.                                 LT_SetAttributes(handle,Node -> Special . Popup . AutoPageID,
  559.                                     LAGR_ActivePage,Node -> Current,
  560.                                 TAG_DONE);
  561.                             }
  562.  
  563.                             NewCurrent = TRUE;
  564.                         }
  565.                     }
  566.  
  567.                     if(Node -> Host)
  568.                     {
  569.                         SetGadgetAttrs(Node -> Host,handle -> Window,NULL,
  570.                             NewCurrent ? PIA_Active : TAG_IGNORE,    Node -> Current,
  571.                             NewLabels ? PIA_Labels : TAG_IGNORE,    Node -> Special . Popup . Choices,
  572.                         TAG_MORE,TagList);
  573.                     }
  574.  
  575.                     return;
  576.                 }
  577. #endif
  578.  
  579. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  580.                 case TAB_KIND:
  581.                 {
  582.                     BOOL NewCurrent = FALSE;
  583.  
  584.                     if(ThisTag = FindTagItem(GA_Disabled,TagList))
  585.                         Node -> Disabled = ThisTag -> ti_Data;
  586.  
  587.                     if(ThisTag = FindTagItem(LATB_Active,TagList))
  588.                     {
  589.                         DB(kprintf("current: %ld tag: %ld\n",Node -> Current,ThisTag -> ti_Data));
  590.  
  591.                         if(Node -> Current != ThisTag -> ti_Data)
  592.                         {
  593.                             Node -> Current = ThisTag -> ti_Data;
  594.  
  595.                             LTP_PutStorage(Node);
  596.  
  597.                             if(Node -> Special . Tab . AutoPageID != -1)
  598.                             {
  599.                                 LT_SetAttributes(handle,Node -> Special . Tab . AutoPageID,
  600.                                     LAGR_ActivePage,Node -> Current,
  601.                                 TAG_DONE);
  602.                             }
  603.  
  604.                             NewCurrent = TRUE;
  605.                         }
  606.                     }
  607.  
  608.                     if(Node -> Host && NewCurrent)
  609.                     {
  610.                         SetGadgetAttrs(Node -> Host,handle -> Window,NULL,
  611.                             TIA_Index,Node -> Current,
  612.                         TAG_MORE,TagList);
  613.                     }
  614.  
  615.                     return;
  616.                 }
  617. #endif
  618.                 case PALETTE_KIND:
  619.  
  620.                     if(ThisTag = FindTagItem(GTPA_Color,TagList))
  621.                     {
  622.                         if(Node -> Current == ThisTag -> ti_Data)
  623.                             Exclude = GTPA_Color;
  624.                         else
  625.                         {
  626.                             Node -> Current = ThisTag -> ti_Data;
  627.  
  628.                             LTP_PutStorage(Node);
  629.  
  630.                             if(Node -> Special . Palette . UsePicker)
  631.                             {
  632.                                 if(Gadget)
  633.                                     LTP_DrawPalette(handle,Node);
  634.  
  635.                                 return;
  636.                             }
  637.                         }
  638.                     }
  639.  
  640.                     break;
  641.  
  642.                 case INTEGER_KIND:
  643.  
  644.                     if(ThisTag = FindTagItem(GTIN_Number,TagList))
  645.                     {
  646.                         LONG num = ThisTag -> ti_Data;
  647.  
  648.                         if(num < Node -> Min)
  649.                             num = Node -> Min;
  650.                         else
  651.                         {
  652.                             if(num > Node -> Max)
  653.                                 num = Node -> Max;
  654.                         }
  655.  
  656.                         if(Gadget)
  657.                         {
  658. #ifdef DO_HEXHOOK
  659.                             if(!Node -> Special . Integer . EditHook || Node -> Special . Integer . CustomHook)
  660.                             {
  661.                                 UBYTE             buffer[20];
  662.                                 struct StringInfo    *stringInfo;
  663.  
  664.                                 sprintf(buffer,"%ld",num);
  665.  
  666.                                 Exclude = GTIN_Number;
  667.  
  668.                                 GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  669.                                     GTST_String,    buffer,
  670.                                     GTIN_Number,    num,
  671.                                 TAG_DONE);
  672.  
  673.                                 stringInfo = (struct StringInfo *)Gadget -> SpecialInfo;
  674.  
  675.                                 stringInfo -> LongInt = num;
  676.                             }
  677.                             else
  678.                             {
  679.                                 UBYTE             buffer[40];
  680.                                 struct StringInfo    *stringInfo;
  681.                                 STRPTR             Index;
  682.                                 LONG             Value,Number = num,
  683.                                              Scale,Sign;
  684.  
  685.                                 stringInfo = (struct StringInfo *)Gadget -> SpecialInfo;
  686.  
  687.                                 Index = stringInfo -> Buffer;
  688.  
  689.                                 while(*Index && *Index == ' ')
  690.                                     Index++;
  691.  
  692.                                 switch(Index[0])
  693.                                 {
  694.                                     case '$':
  695.  
  696.                                         sprintf(buffer,"$%lx",num);
  697.                                         break;
  698.  
  699.                                     case '&':
  700.  
  701.                                         if(Number < 0)
  702.                                         {
  703.                                             Sign = -1;
  704.                                             Number = -Number;
  705.                                         }
  706.                                         else
  707.                                             Sign = 1;
  708.  
  709.                                         for(Value = 0, Scale = 1 ; Number ; Number /= 8, Scale *= 10)
  710.                                             Value += (Number & 7) * Scale;
  711.  
  712.                                         sprintf(buffer,"&%ld",Sign * Value);
  713.                                         break;
  714.  
  715.                                     case '%':
  716.  
  717.                                         if(Number < 0)
  718.                                         {
  719.                                             Sign = -1;
  720.                                             Number = -Number;
  721.                                         }
  722.                                         else
  723.                                             Sign = 1;
  724.  
  725.                                         for(Value = 0, Scale = 1 ; Number ; Number /= 2, Scale *= 10)
  726.                                             Value += (Number & 1) * Scale;
  727.  
  728.                                         sprintf(buffer,"%%%ld",Sign * Value);
  729.                                         break;
  730.  
  731.                                     case '0':
  732.  
  733.                                         if(Index[1] == 'x')
  734.                                         {
  735.                                             sprintf(buffer,"0x%lx",num);
  736.                                             break;
  737.                                         }
  738.  
  739.                                         // Fall through to...
  740.  
  741.                                     default:
  742.  
  743.                                         sprintf(buffer,"%ld",num);
  744.                                         break;
  745.                                 }
  746.  
  747.                                 Exclude = GTIN_Number;
  748.  
  749.                                 GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  750.                                     GTST_String,buffer,
  751.                                 TAG_DONE);
  752.  
  753.                                 stringInfo -> LongInt = num;
  754.                             }
  755. #else
  756.                             GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  757.                                 GTIN_Number,num,
  758.                             TAG_DONE);
  759. #endif
  760.                         }
  761.  
  762.                         Node -> Special . Integer . Number = num;
  763.  
  764.                         LTP_PutStorage(Node);
  765.                     }
  766.  
  767.                     break;
  768.  
  769.                 case SLIDER_KIND:
  770.  
  771.                     if(ThisTag = FindTagItem(GTSL_Level,TagList))
  772.                     {
  773.                         if(Node -> Current == ThisTag -> ti_Data)
  774.                             Exclude = GTSL_Level;
  775.                         else
  776.                         {
  777.                             Node -> Current = ThisTag -> ti_Data;
  778.  
  779.                             LTP_PutStorage(Node);
  780.                         }
  781.                     }
  782.  
  783.                     if(ThisTag = FindTagItem(GTSL_Min,TagList))
  784.                     {
  785.                         Node -> Min = ThisTag -> ti_Data;
  786.  
  787.                         if(Node -> Current < Node -> Min)
  788.                         {
  789.                             Node -> Current = Node -> Min;
  790.  
  791.                             LTP_PutStorage(Node);
  792.                         }
  793.                     }
  794.  
  795.                     if(ThisTag = FindTagItem(GTSL_Max,TagList))
  796.                     {
  797.                         Node -> Max = ThisTag -> ti_Data;
  798.  
  799.                         if(Node -> Current > Node -> Max)
  800.                         {
  801.                             Node -> Current = Node -> Max;
  802.  
  803.                             LTP_PutStorage(Node);
  804.                         }
  805.                     }
  806.  
  807.                     break;
  808.  
  809.                 case SCROLLER_KIND:
  810.  
  811.                     if(ThisTag = FindTagItem(GTSC_Top,TagList))
  812.                     {
  813.                         if(Node -> Current == ThisTag -> ti_Data)
  814.                             Exclude = GTSC_Top;
  815.                         else
  816.                         {
  817.                             Node -> Current = ThisTag -> ti_Data;
  818.  
  819.                             LTP_PutStorage(Node);
  820.                         }
  821.                     }
  822.  
  823.                     if(ThisTag = FindTagItem(GTSC_Total,TagList))
  824.                     {
  825.                         Node -> Max = ThisTag -> ti_Data;
  826.  
  827.                         if(Node -> Current > Node -> Max)
  828.                         {
  829.                             Node -> Current = Node -> Max;
  830.  
  831.                             LTP_PutStorage(Node);
  832.                         }
  833.                     }
  834.  
  835.                     if(ThisTag = FindTagItem(GTSC_Visible,TagList))
  836.                         Node -> Special . Scroller . Visible = ThisTag -> ti_Data;
  837.  
  838.                     break;
  839.  
  840.                 case BOX_KIND:
  841.                 {
  842.                     BOOLEAN Visible = Node -> Special . Box . Parent -> Special . Group . Visible;
  843.  
  844.                     if(ThisTag = FindTagItem(LABX_Index,TagList))
  845.                     {
  846.                         LONG Index = ThisTag -> ti_Data;
  847.  
  848.                         if(Index >= 0 && Index < Node -> Lines)
  849.                         {
  850.                             if(ThisTag = FindTagItem(LABX_Text,TagList))
  851.                             {
  852.                                 if(Node -> Special . Box . ReserveSpace)
  853.                                 {
  854.                                     STRPTR    Text = (STRPTR)ThisTag -> ti_Data;
  855.                                     WORD    Len = strlen(Text);
  856.  
  857.                                     if(Len > Node -> Special . Box . MaxSize)
  858.                                         Len = Node -> Special . Box . MaxSize;
  859.  
  860.                                     CopyMem(Text,Node -> Special . Box . Lines[Index],Len);
  861.  
  862.                                     Node -> Special . Box . Lines[Index][Len] = 0;
  863.                                 }
  864.                                 else
  865.                                     Node -> Special . Box . Lines[Index] = (STRPTR)ThisTag -> ti_Data;
  866.  
  867.                                 if(Visible)
  868.                                     LTP_PrintBoxLine(handle,Node,Index);
  869.                             }
  870.                         }
  871.                     }
  872.  
  873.                     if(ThisTag = FindTagItem(LABX_Lines,TagList))
  874.                     {
  875.                         STRPTR    *Lines = (STRPTR *)ThisTag -> ti_Data;
  876.                         LONG     i;
  877.  
  878.                         if(Node -> Special . Box . ReserveSpace)
  879.                         {
  880.                             WORD Len;
  881.  
  882.                             for(i = 0 ; i < Node -> Lines ; i++)
  883.                             {
  884.                                 if(Lines[i])
  885.                                 {
  886.                                     Len = strlen(Lines[i]);
  887.  
  888.                                     if(Len > Node -> Special . Box . MaxSize)
  889.                                         Len = Node -> Special . Box . MaxSize;
  890.  
  891.                                     CopyMem(Lines[i],Node -> Special . Box . Lines[i],Len);
  892.  
  893.                                     Node -> Special . Box . Lines[i][Len] = 0;
  894.  
  895.                                     if(Visible)
  896.                                         LTP_PrintBoxLine(handle,Node,i);
  897.                                 }
  898.                                 else
  899.                                     break;
  900.                             }
  901.                         }
  902.                         else
  903.                         {
  904.                             for(i = 0 ; i < Node -> Lines ; i++)
  905.                             {
  906.                                 if(Lines[i])
  907.                                 {
  908.                                     Node -> Special . Box . Lines[i] = Lines[i];
  909.  
  910.                                     if(Visible)
  911.                                         LTP_PrintBoxLine(handle,Node,i);
  912.                                 }
  913.                                 else
  914.                                     break;
  915.                             }
  916.                         }
  917.                     }
  918.  
  919.                     break;
  920.                 }
  921.  
  922.                 case TEXT_KIND:
  923.  
  924.                     if(ThisTag = FindTagItem(GTTX_Text,TagList))
  925.                     {
  926.                         STRPTR text = (STRPTR)ThisTag -> ti_Data;
  927.  
  928.                         if(!text)
  929.                             text = "";
  930.  
  931.                         if(Node -> Special . Text . CopyText)
  932.                         {
  933.                             LONG len;
  934.  
  935.                             if(Node -> Special . Text . Text)
  936.                                 len = strlen(Node -> Special . Text . Text) + 1;
  937.                             else
  938.                                 len = 0;
  939.  
  940.                             if(len)
  941.                                 LTP_Free(handle,Node -> Special . Text . Text,len);
  942.  
  943.                             len = strlen(text);
  944.  
  945.                             if(Node -> Special . Text . Text = LTP_Alloc(handle,len + 1))
  946.                                 strcpy(Node -> Special . Text . Text,text);
  947.                         }
  948.                         else
  949.                             Node -> Special . Text . Text = text;
  950.                     }
  951.  
  952.                     break;
  953.  
  954.                 case GROUP_KIND:
  955.  
  956.                     if(Node -> Special . Group . Paging)
  957.                     {
  958.                         if(ThisTag = FindTagItem(LAGR_ActivePage,TagList))
  959.                         {
  960.                             ObjectNode *node;
  961.  
  962.                             node = Node;
  963.  
  964. //                            if(node = LTP_FindNode(handle -> TopGroup,id))
  965.                             {
  966.                                 if(node -> Type == GROUP_KIND)
  967.                                 {
  968.                                     if(node -> Special . Group . ActivePage != ThisTag -> ti_Data)
  969.                                     {
  970.                                         WORD    Left    = node -> Left,
  971.                                             Top    = node -> Top,
  972.                                             Width    = node -> Width,
  973.                                             Height    = node -> Height;
  974.  
  975.                                         if(node -> Label || node -> Special . Group . Frame)
  976.                                         {
  977.                                             Left    += 4 + handle -> GlyphWidth;
  978.                                             Width    -= 2 * (4 + handle -> GlyphWidth);
  979.  
  980.                                             if(node -> Label)
  981.                                             {
  982.                                                 Top    += handle -> RPort . TxHeight;
  983.                                                 Height    -= handle -> RPort . TxHeight + 3;
  984.                                             }
  985.                                             else
  986.                                             {
  987.                                                 Top    += 2;
  988.                                                 Height    -= 5;
  989.                                             }
  990.                                         }
  991.  
  992.                                         node -> Special . Group . ActivePage = ThisTag -> ti_Data;
  993.  
  994.                                         LT_LockWindow(handle -> Window);
  995.  
  996.                                         EraseRect(&handle -> RPort,Left,Top,Left + Width - 1,Top + Height - 1);
  997.  
  998.                                         LT_RebuildTagList(handle,FALSE,NULL);
  999.  
  1000.                                         LT_UnlockWindow(handle -> Window);
  1001.                                     }
  1002.                                 }
  1003.                             }
  1004.                         }
  1005.                     }
  1006.  
  1007.                     break;
  1008.             }
  1009.  
  1010.             if(ThisTag = FindTagItem(LA_LabelText,TagList))
  1011.                 Node -> Label = (STRPTR)ThisTag -> ti_Data;
  1012.  
  1013.             if(ThisTag = FindTagItem(LA_LabelID,TagList))
  1014.             {
  1015.                 if(handle -> LocaleHook)
  1016.                     Node -> Label = (STRPTR)CallHookPkt(handle -> LocaleHook,handle,(APTR)ThisTag -> ti_Data);
  1017.             }
  1018.  
  1019.             if(ThisTag = FindTagItem(GA_Disabled,TagList))
  1020.             {
  1021.                 if((Node -> Disabled && ThisTag -> ti_Data) || (!Node -> Disabled && !ThisTag -> ti_Data))
  1022.                 {
  1023.                     if(!NewTags)
  1024.                         NewTags = CloneTagItems(TagList);
  1025.  
  1026.                     if(NewTags)
  1027.                         FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  1028.                 }
  1029.                 else
  1030.                 {
  1031.                     Node -> Disabled = ThisTag -> ti_Data;
  1032.  
  1033.                     if(Gadget)
  1034.                     {
  1035.                         struct Gadget *gad;
  1036.  
  1037.                         switch(Node -> Type)
  1038.                         {
  1039. #ifdef DO_LEVEL_KIND
  1040.                             case LEVEL_KIND:
  1041.  
  1042.                                 gad = Gadget;
  1043.                                 break;
  1044. #endif    /* DO_LEVEL_KIND */
  1045.                             case TEXT_KIND:
  1046.  
  1047.                                 gad = Node -> Special . Text . Picker;
  1048.                                 break;
  1049.  
  1050.                             case STRING_KIND:
  1051.  
  1052.                                 gad = Node -> Special . String . Picker;
  1053.                                 break;
  1054.  
  1055.                             case INTEGER_KIND:
  1056.  
  1057.                                 if(gad = Node -> Special . Integer . LeftIncrementer)
  1058.                                 {
  1059.                                     RemoveGList(handle -> Window,handle -> List,(UWORD)-1);
  1060.  
  1061.                                     if(Node -> Disabled)
  1062.                                         gad -> Flags |= GFLG_DISABLED;
  1063.                                     else
  1064.                                         gad -> Flags &= ~GFLG_DISABLED;
  1065.  
  1066.                                     AddGList(handle -> Window,handle -> List,(UWORD)-1,(UWORD)-1,NULL);
  1067.                                     RefreshGList(gad,handle -> Window,NULL,1);
  1068.                                 }
  1069.  
  1070.                                 gad = Node -> Special . Integer . RightIncrementer;
  1071.                                 break;
  1072.  
  1073.                             case TAPEDECK_KIND:
  1074.  
  1075.                                 gad = Node -> Host;
  1076.  
  1077.                                 Gadget = NULL;
  1078.  
  1079.                                 break;
  1080.  
  1081.                             case BUTTON_KIND:
  1082.  
  1083.                                 if(Node -> Special . Button . ButtonImage)
  1084.                                 {
  1085.                                     gad = Node -> Host;
  1086.  
  1087.                                     Gadget = NULL;
  1088.  
  1089.                                     break;
  1090.                                 }
  1091.  
  1092.                                 // FALLS THROUGH TO
  1093.  
  1094.                             default:
  1095.  
  1096.                                 gad = NULL;
  1097.                                 break;
  1098.                         }
  1099.  
  1100.                         if(gad)
  1101.                         {
  1102.                             RemoveGList(handle -> Window,handle -> List,(UWORD)-1);
  1103.  
  1104.                             if(Node -> Disabled)
  1105.                                 gad -> Flags |= GFLG_DISABLED;
  1106.                             else
  1107.                                 gad -> Flags &= ~GFLG_DISABLED;
  1108.  
  1109.                             AddGList(handle -> Window,handle -> List,(UWORD)-1,(UWORD)-1,NULL);
  1110.                             RefreshGList(gad,handle -> Window,NULL,1);
  1111.                         }
  1112.                     }
  1113.                 }
  1114.             }
  1115.  
  1116.             if(Exclude)
  1117.             {
  1118.                 ULONG Filter[2];
  1119.  
  1120.                 Filter[0] = Exclude;
  1121.                 Filter[1] = TAG_DONE;
  1122.  
  1123.                 if(!NewTags)
  1124.                     NewTags = CloneTagItems(TagList);
  1125.  
  1126.                 if(NewTags)
  1127.                     FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  1128.             }
  1129.  
  1130.             if(Gadget)
  1131.             {
  1132.                 struct TagItem *tags = TagList;
  1133.  
  1134.                 if(NewTags)
  1135.                     tags = NewTags;
  1136.  
  1137.                 if(!V39 && Node -> Disabled && Node -> Type == SLIDER_KIND)
  1138.                 {
  1139.                     GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  1140.                         GA_Disabled,    FALSE,
  1141.                     TAG_MORE,tags);
  1142.  
  1143.                     GT_SetGadgetAttrs(Gadget,handle -> Window,NULL,
  1144.                         GA_Disabled,    TRUE,
  1145.                     TAG_DONE);
  1146.                 }
  1147.                 else
  1148.                     GT_SetGadgetAttrsA(Gadget,handle -> Window,NULL,tags);
  1149.             }
  1150.  
  1151.             if(Node -> Type == STRING_KIND || Node -> Type == FRACTION_KIND || Node -> Type == PASSWORD_KIND)
  1152.                 LTP_PutStorage(Node);
  1153.  
  1154.             FreeTagItems(NewTags);
  1155.         }
  1156.     }
  1157. }
  1158.